package pro.softzhang.algo.lc100;

import pro.softzhang.algo.flag.book.BOfferII;
import pro.softzhang.algo.flag.knowledge.KStack;
import pro.softzhang.algo.flag.theme.TDesign;

import java.util.Stack;

@KStack
@BOfferII(30)
@TDesign
public class LC155_MinStack {
    public static void main(String[] args) {

    }

    static
    class MinStack {
        private Stack<Integer> data = new Stack(), min = new Stack<>();

        public MinStack() {}

        public void push(int x) {
            data.push(x);
            min.push((min.isEmpty() || x < min.peek()) ? x : min.peek());
        }

        public void pop() {
            data.pop();
            min.pop();
        }

        public int top() {
            return data.peek();
        }

        public int min() {
            return min.peek();
        }
    }
}
